<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <!--<link rel="stylesheet" href="css/iview.min.css">-->
    <!--<link rel="stylesheet" type="text/css" href="http://unpkg.com/iview/dist/styles/iview.css">-->
    <link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.ico">
    <title>壹脉智能CRM</title>
    <!-- Bootstrap Core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">
    <!-- <link href="../assets/node_modules/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet"> -->
    <!-- This page CSS -->
    <!-- chartist CSS -->
    <!-- <link href="../assets/node_modules/morrisjs/morris.css" rel="stylesheet"> -->
    <!--c3 CSS -->
    <!-- <link href="../assets/node_modules/c3-master/c3.min.css" rel="stylesheet"> -->
    <!--Toaster Popup message CSS -->
    <!-- <link href="../assets/node_modules/toast-master/css/jquery.toast.css" rel="stylesheet"> -->
    <!-- Custom CSS -->
    <link href="css/style.min.css" rel="stylesheet">
    <!-- Dashboard 1 Page CSS -->
    <!--<link href="css/pages/dashboard1.css" rel="stylesheet">-->
    <!-- You can change the theme colors from here -->
    <link href="css/colors/default.css" id="theme" rel="stylesheet">
    <link rel="stylesheet" href="css/diy.min.css">
    <!--<link href="../assets/node_modules/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="../assets/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css"/>-->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="fix-header fix-sidebar card-no-border">
<div class="preloader">
    <div class="loader">
        <div class="loader__figure"></div>
        <p class="loader__label">壹脉</p>
    </div>
</div>
<div id="main-wrapper">
    <header class="topbar">
        <nav class="navbar top-navbar navbar-expand-md navbar-light">
            <div class="navbar-header">
                <a class="navbar-brand" href="../index.html">
                    <b>
                        <img src="../assets/images/diy/yimai.png" alt="homepage" class="dark-logo"/>
                        <!--<img src="../assets/images/logo-light-icon.png" alt="homepage" class="light-logo"/>-->
                    </b>
                    <span>
                        <span class="fs18 cblue p-l-6 fbold">壹脉智能CRM</span>
                    </span>
                </a>
            </div>
            <div class="navbar-collapse">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item"><a class="nav-link nav-toggler hidden-md-up waves-effect waves-dark"
                                            href="javascript:void(0)"><i class="sl-icon-menu"></i></a></li>
                    <li class="nav-item"><a class="nav-link sidebartoggler hidden-sm-down waves-effect waves-dark"
                                            href="javascript:void(0)"><i class="sl-icon-menu"></i></a></li>
                </ul>
                <user-head></user-head>
            </div>
        </nav>
    </header>
    <aside class="left-sidebar">
        <company-position></company-position>
        <div class="scroll-sidebar">
            <nav class="sidebar-nav p-0">
                <c-slider current="5"></c-slider>
            </nav>
        </div>
    </aside>
    <div class="page-wrapper">

        <div class="container-fluid">

            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-themecolor">员工详情</h3>
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">HOME</a></li>
                        <li class="breadcrumb-item active">企业管理</li>
                        <li class="breadcrumb-item active">
                            <a href="/main/memberList.html">
                                员工列表
                            </a>
                        </li>
                        <li class="breadcrumb-item active">员工详情</li>
                    </ol>
                </div>
            </div>

            <div class="bgfff p-t-30 p-l-30 p-r-31 p-b-30 m-b-20">
                <div class="fs14 p-t-18 p-b-15">基本资料</div>

                <table class="align-cen-table textc display nowrap table table-hover table-bordered bgf6f9fa m-b-20">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>姓名</th>
                        <th>手机号码</th>
                        <th>微信号码</th>
                        <th>职位</th>
                        <th>独占客户数</th>
                        <th>成单客户数</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody class="bgfff">
                    <tr class="curpointer" >
                        <td>{{memberInfo.cardId}}</td>
                        <td>{{memberInfo.name}}</td>
                        <td>{{memberInfo.phone}}</td>
                        <td>{{memberInfo.personalWx}}</td>
                        <td>{{memberInfo.position}}</td>
                        <td>{{memberInfo.num}}</td>
                        <td>{{memberInfo.dealNum}}</td>
                        <td>{{memberInfo.createTime | formatDate('yyyy-MM-dd hh:mm')}}</td>
                        <td class="lh30 fs14 p-r-30 clearfix text-danger">
                            <span @click="delMember">
                                删除
                            </span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div class="ml-auto d-flex align-cen jsend m-b-20">
                <div class="m-r-21">
                    <div class="form-group m-b-0 w241">
                        <input type="text" id="company" class="form-control p-l-23 phgray"
                               placeholder="请输入姓名或电话用户" v-model="searchKey">
                    </div>
                </div>
                <span class="bgblue p-l-20 p-r-19 bradius4 m-r-10 cfff fs14 lh30">查询</span>
            </div>
            <div class="bgfff">
                <ul class="nav nav-tabs customtab">
                    <li class="nav-item" v-for="tab in tabs" :key="tab.type" @click="changeType(tab.type)">
                        <span class="nav-link" :class="countType==tab.type ? 'active' : ''">{{tab.label}}</span>
                    </li>
                </ul>
                <div class="d-flex p-t-20 w100p p-r-31 p-b-17 p-l-30">
                    <span class="bgblue p-l-20 p-r-19 bradius4 m-r-10 cfff fs14 lh30" @click="showMoveClientBox('batch')">批量移交</span>
                </div>


                <div class="row w100p p-l-30">
                    <div class="col-12">
                        <div class="card m-b-0">
                            <table id="example23" class="align-cen-table textc display nowrap table table-hover table-bordered bgf6f9fa m-b-20">
                                <thead>
                                <tr>
                                    <th>
                                        <!--<input type="checkbox">-->
                                        <span class="w16 h16 bradius4 bced d-inline-block mdi position-relative top3"
                                              :class="allChecks? 'mdi-check checks' : '' "
                                              @click="checkAll"
                                        ></span>
                                    </th>
                                    <th>序号</th>
                                    <th>姓名</th>
                                    <th>手机号码</th>
                                    <th>微信号码</th>
                                    <th>创建时间</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody class="bgfff">
                                <tr v-for="(v,k) in clientLists" :key="k" class="curpointer">
                                    <td @click.stop="">
                                        <span class="w16 h16 bradius4 bced d-inline-block mdi position-relative top3"
                                              :class="selectRows.includes(v) ? 'mdi-check checks':''"
                                              @click.stop="chooseRow(v)"></span>
                                    </td>
                                    <td>{{v.customerId}}</td>
                                    <td>{{v.name}}</td>
                                    <td>{{v.phone}}</td>
                                    <td>{{v.personalWx}}</td>
                                    <td>{{v.inputDate}}</td>
                                    <td>{{v.customerRemark}}</td>
                                    <td>
                                        <span class="d-inline-block cblue curpointer" @click="showMoveClientBox('one', v)">移交</span>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <div class="textc" v-if=" !clientLists.length || clientLists.length < 0">暂无数据</div>
                        </div>


                        <!--分页-->
                        <div class="d-flex p-b-50 jsend">
                            <page-helper :page-number="page" :total-count="total" @change="jumpPage"></page-helper>
                        </div>

                    </div>

                </div>
            </div>
        </div>

    </div>

    <!--移至成员-->
    <select-member v-model="ascriptionId"
                   :is-show="to_member_show"
                   :is-show-share="true"
                   @confirm="moveCustomer(1)"
                   @confirm-to-share="moveCustomer"
                   @cancel="to_member_show=false">
    </select-member>

</div>
<!-- All Jquery -->
<!-- ============================================================== -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap popper Core JavaScript -->
<!-- <script src="../assets/node_modules/bootstrap/js/popper.min.js"></script> -->
<script src="js/bootstrap.min.js"></script>
<!--<script src="js/iview.min.js"></script>-->
<!--<link rel="stylesheet" type="text/css" href="http://unpkg.com/iview/dist/styles/iview.css">-->
<!--<script type="text/javascript" src="http://unpkg.com/iview/dist/iview.min.js"></script>-->
<!-- slimscrollbar scrollbar JavaScript -->
<script src="js/perfect-scrollbar.jquery.min.js"></script>
<!--Wave Effects -->
<!-- <script src="js/waves.js"></script> -->
<!--Menu sidebar -->
<script src="js/sidebarmenu.js"></script>
<!--Custom JavaScript -->
<script src="js/custom.min.js"></script>
<!-- ============================================================== -->
<!-- This page plugins -->
<!-- ============================================================== -->
<!--morris JavaScript -->
<!-- <script src="../assets/node_modules/raphael/raphael-min.js"></script>
<script src="../assets/node_modules/morrisjs/morris.min.js"></script> -->
<!--c3 JavaScript -->
<!-- <script src="../assets/node_modules/d3/d3.min.js"></script>
<script src="../assets/node_modules/c3-master/c3.min.js"></script> -->
<!-- Popup message jquery -->
<!-- <script src="../assets/node_modules/toast-master/js/jquery.toast.js"></script> -->
<!-- Chart JS -->
<!--<script src="js/dashboard1.js"></script>-->
<!-- ============================================================== -->
<!-- Style switcher -->
<!-- ============================================================== -->
<!-- <script src="../assets/node_modules/styleswitcher/jQuery.style.switcher.js"></script> -->
<!--<script src="../assets/node_modules/bootstrap-table/dist/bootstrap-table.min.js"></script>
<script src="../assets/node_modules/bootstrap-table/dist/bootstrap-table.ints.js"></script>-->
<script src="js/vue.js"></script>
<script src="js/layer/layer.js"></script>
<script src="js/config.js"></script><script src="js/extend.js"></script>
<!--<script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>-->

<!--<script src="js/headers.js"></script>-->
<!--<script src="js/Aside.js"></script>-->

<script>
    $(function () {
        var vw = new Vue({
            el: '#main-wrapper',
            // components:{header},
            data: {
                search_key: '',//搜索关键字
                searchCondition: '',
                memberInfo: {},
                to_member_show:false ,//移至成员
                ascriptionId: '',
                searchKey: '',
                countType: 1,
                tabs: [
                    { type: 1, label: '独占客户' },
                    { type: 3, label: '成单客户' },
                ],
                // 选中列表
                selectRows: [],
                // 客户列表
                clientLists: [],
                total: 0,
                page: 1,
                moveState: '',
                cardId: '',
                currentClient: {},
            },
            mounted() {
                this.cardId = $.formatParams(location.href).id;
                this.getMemberClient();
                this.getMemberInfo();
            },
            methods: {
                checkAll(){
                    this.allChecks = !this.allChecks;
                },
                jumpPage({currentPage}){
                    this.page = currentPage;
                    this.getMemberClient();
                },
                showMoveClientBox(state, clientInfo){
                    if (state=='batch' && !this.selectRows.length){
                        layer.alert('请选择客户');
                        return;
                    }

                    this.moveState = state;
                    this.to_member_show=true

                    if (state != 'bath') {
                        this.currentClient = clientInfo;
                    }
                },
                delMember(){
                    layer.confirm('<p>是否确认删除该员工？</p><p>删除员工前请确保该员工所拥有的客户已全部移除</p>', {
                        skin: 'confirm-class',
                        btn: ['取消', '确定']
                    }, (idx)=>{
                        layer.close(idx);
                    },() =>{
                        $.cAjax('/crmPc/businessCard/quitCompany', {
                            data:{
                                cardId: this.cardId,
                                userId: this.memberInfo.userId,
                            }
                        }).then( (data) =>{
                            layer.msg('删除成功');
                            setTimeout(function () {
                                location.href = location.origin+'/main/memberList.html';
                            }, 1.5*1000);
                        }).catch(function (err) {
                        });
                    });
                },
                changeType(type){
                    this.countType= type;
                    this.page = 1;
                    this.getMemberClient();
                },
                getMemberInfo(){
                    $.cAjax('/crmPc/businessCard/getCompanyStaffInfo', {
                        data:{
                            cardId: this.cardId,
                        }
                    }).then(res=>{
                        this.memberInfo = res;
                    })
                },
                // 获取当前员工的客户
                getMemberClient(){
                    $.cAjax('/crmPc/customer/getCustomerPC',{
                        data:{
                            type: 1,
                            pageNum:this.page,
                            name: this.searchKey,
                            cardId: this.cardId,
                            customerState: this.countType
                        }
                    }).then(res=>{
                        this.clientLists = res.pageInfo.list || [];
                        this.total = res.pageInfo.total;
                    })
                },
                chooseRow(row){
                    let idx = this.selectRows.indexOf(row);
                    if (idx != -1){
                        this.selectRows.splice(idx, 1);
                    } else {
                        this.selectRows.push(row);
                    }
                },
                // 移动客户
                moveCustomer(customerState) {
                    if (customerState==1 && !this.ascriptionId) {
                        layer.alert('请选择移交给的员工');
                        return;
                    }
                    let customerIds;

                    if (this.moveState == 'batch') {
                        customerIds = this.selectRows.map(val=>val.customerId).join(',');
                    }else{
                        customerIds = this.currentClient.customerId;
                    }

                    $.cAjax('/crmPc/customer/moveCustomer', {
                        data:{
                            customerIds: customerIds,
                            customerState: customerState,
                            ascriptionId: this.ascriptionId,
                        }
                    }).then((data) => {
                        layer.alert(customerState == 1 ? '已移交给其他员工' : '移至共享成功', {time: 1500});
                        this.page = 1;
                        this.getMemberClient();
                        this.to_member_show = false;
                    });
                },
                tomember(){//移至成员
                    this.ascriptionId = '';
                    this.to_member_show = !this.to_member_show ;
                },

            },
            computed:{
                allChecks:{
                    get(){
                        return this.selectRows.length && (this.selectRows.length == this.clientLists.length);
                    },
                    set(val){
                        if(val){
                            this.selectRows= [...this.clientLists];
                        }else{
                            this.selectRows = [];
                        }
                    },
                }
            },
        })
    })
</script>

</body>

</html>












